<%#
kind: snippet
name: fix_hosts
model: ProvisioningTemplate
snippet: true
description: |
  Used in user_data templates for setting the correct content of the /etc/hosts file.
  The goal is to potentially fix incorrect hosts file that is baked in the image
  used for the provisioning.
-%>
echo "<%= @host.shortname %>" > /etc/hostname
<% if @host.operatingsystem.family == 'Redhat' && @host.operatingsystem.major.to_i == 6 %>
hostname <%= @host %>
<% else %>
hostname <%= @host.shortname %>
<% end %>
cat > /etc/hosts << EOF
<%# simple snippet to generate /etc/hosts when provisioning image based systems -%>
127.0.0.1   <%= @host %> <%= @host.shortname %> localhost localhost.localdomain
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
